<extend name="Public/Dialog/Common"/>
<block name="pageContent">
    <div class="bjui-pageContent">
        <form action="{:U('update')}" class="pageForm" data-toggle="validate" method="post">
            <!-- 菜单id号 -->
            <input type="hidden" name="id" value="{$data.id|default=I('id')}"/>
            <input type="hidden" name="pid" value="{$data.pid|default=''}"/>
            <input type="hidden" name="model_id" value="{$data.model_id|default=I('model_id')}"/>
            <input type="hidden" name="group_id" value="{$data.group_id|default=''}"/>
            <input type="hidden" name="category_id" value="{$data.category_id|default=''}">

                <div class="col-md-8">
                    <div class="col-md-12">
                        <div class="panel panel-default">
                            <div class="panel-body">
                                标题：<input type="text" value="{$data['title']}" name="title" class="text input-large form-control" size="50">
                            </div>
                        </div>
                    </div>
                    <div class="col-md-12">
                        <div class="panel panel-default">
                            <div class="panel-body">
                                来源：<input type="text" value="{$data['source']}" name="source" class="text input-large form-control" size="50">
                            </div>
                        </div>
                    </div>
                    <div class="col-md-12">
                        <div class="panel panel-default">
                            <div class="panel-body">
                                描述：<input type="text" value="{$data['description']}" name="description" class="text input-large form-control" size="50">
                            </div>
                        </div>
                    </div>
                    <div class="col-md-12">
                        <div class="panel panel-default">
                            <div class="panel-heading">
                                内容
                            </div>
                            <div class="panel-body">
                                <label class="textarea">
                                    <textarea name="content" data-toggle="kindeditor" data-minheight="200" style="width: 800px;">{$data['content']}</textarea>
                                </label>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-md-4">
                    <!--<div class="col-md-12">
                        <div class="panel panel-default">
                            <div class="panel-heading">
                                多图
                            </div>
                            <div class="panel-body">
                                <input type="file" id="upload_all_{$data.id}">
                                <input type="hidden" name="uploadpics" value="{$data[$field['name']]}" id="input_upload_all{$data.id}"/>
                                <div id="uploadpics_piclist{$data.id}">
                                    <ul class="highslide-gallery">
                                        <notempty name="data[$field['name']]">
                                            <?php
                                                         $pics=explode(',', $data['uploadpics']);
                                                         foreach($pics as $v){
                                                         if($v!=''){
                                                         ?>
                                            <li>
                                                <a href="__ROOT{$v|get_cover='path'}" target="_blank">
                                                    <img src="__ROOT{$v|get_cover='path'}" style="max-width:500px;max-height:200px;"/></a>
                                                <span onclick="delthispics{$data.id}(this)" dataid="{$v}," class="fa fa-trash" style="font-size:20px;"></span>
                                            </li>
                                            <?php
                                                         }
                                                         }
                                                         ?>
                                        </notempty>
                                    </ul>
                                </div>
                                <script type="text/javascript">
                                    //上传多图
                                    $.CurrentNavtab.find("#upload_all_{$data.id}").uploadify({
                                        "height" : 30,
                                        "swf" : "__BJUI/plugins/uploadify/scripts/uploadify.swf",
                                        "fileObjName" : "download",
                                        "buttonText" : "批量上传图片",
                                        "uploader" : "{:U('File/uploadPicture',array('session_id'=>session_id()))}",
                                        "width" : 120,
                                        'removeTimeout' : 1,
                                        'fileTypeExts' : '*.jpg; *.png; *.gif;',
                                        "onUploadSuccess" : function(file, data){
                                            var data = $.parseJSON(data);
                                            var src = '';
                                            if(data.status){
                                                src = data.url || '__ROOT' + data.path;
                                                var value = '<li>' +
                                                        '<a href="'+src+'" class="highslide" onClick="return hs.expand(this)">' +
                                                        '<img src="' + src + '" style="max-width:1000px;max-height:200px;"/></a>' +
                                                        '<span onclick="delthispics{$data.id}(this)" dataid="'+data.id+'," class="fa fa-trash" style="font-size:20px;"></span>' +
                                                        '</li>';

                                                // 图片数据
                                                $.CurrentNavtab.find('#uploadpics_piclist{$data.id} ul').append(value);

                                                // 更新图片id数据
                                                var dataids = "";
                                                console.log($.CurrentNavtab.find('#uploadpics_piclist{$data.id} .fa-trash').length);
                                                $.CurrentNavtab.find('#uploadpics_piclist{$data.id} .fa-trash').each(function(){
                                                    dataids += $(this).attr('dataid');
                                                })
                                                console.log(dataids);
                                                $.CurrentNavtab.find('#input_upload_all{$data.id}').val(dataids);
                                            } else {
                                                $(this).alertmsg('error', data.info);
                                            }
                                        },
                                        'onFallback' : function() {
                                            alert('未检测到兼容版本的Flash.');
                                        }
                                    });
                                    /**
                                     * 删除多图, 更新数据
                                     */
                                    function delthispics{$data.id}(obj) {
                                        var dataids = '';   // 图片标识数据
                                        $(obj).parent().remove();               // 移除父结点
                                        // 更新数据
                                        $.CurrentNavtab.find('#uploadpics_piclist{$data.id} .fa-trash').each(function(){
                                            dataids += $(this).attr('dataid');
                                        })
                                        $.CurrentNavtab.find('#input_upload_all{$data.id}').val(dataids);
                                    }
                                </script>
                            </div>
                        </div>
                    </div>-->
                    <div class="col-md-12">
                        <div class="panel panel-default">
                            <div class="panel-heading">
                                封面
                            </div>
                            <div class="panel-body">
                                <div class="controls">
                                    <input type="file" id="upload_picture_{$data.id}">
                                    <input type="hidden" name="cover_id" value="{$data['cover_id']}" id="cover_id_{$data.id}"/>
                                    <div class="upload-img-box">
                                        <notempty name="data['cover_id']">
                                            <div class="upload-pre-item">
                                                <img src="{$data['cover_id']|get_cover='path'}" style="max-width:500px;max-height:200px;"/>
                                                <span onclick="delthispic{$data.id}(this)" dataid="{$v}," class="fa fa-trash" style="font-size:20px;"></span>
                                            </div>
                                        </notempty>
                                    </div>
                                </div>
                                <script type="text/javascript">
                                    //上传单图
                                    $.CurrentNavtab.find("#upload_picture_{$data.id}").uploadify({
                                        "height"          : 30,
                                        "swf"             : "__BJUI/plugins/uploadify/scripts/uploadify.swf",
                                        "fileObjName"     : "download",
                                        "buttonText"      : "上传图片",
                                        "uploader"        : "{:U('File/uploadPicture',array('session_id'=>session_id()))}",
                                        "width"           : 120,
                                        'removeTimeout'	  : 1,
                                        'fileTypeExts'	  : '*.jpg; *.png; *.gif;',
                                        "onUploadSuccess" : function(file, data){
                                            var data = $.parseJSON(data);
                                            var src = '';
                                            console.log(data);
                                            if(data.status){
                                                $.CurrentNavtab.find("#cover_id_{$data.id}").val(data.id);
                                                src = data.url || '__ROOT' + data.path
                                                $.CurrentNavtab.find("#cover_id_{$data.id}").parent().find('.upload-img-box').html(
                                                        '<div class="upload-pre-item">' +
                                                                '<img src="' + src + '" style="max-width:500px;max-height:200px;"/>' +
                                                                '<span onclick="delthispic{$data.id}(this)" dataid="{$v}," class="fa fa-trash" style="font-size:20px;"></span>'+
                                                                '</div>'
                                                );
                                            } else {
                                                $(this).alertmsg('error', data.info);
                                            }
                                        },
                                        'onFallback' : function() {
                                            alert('未检测到兼容版本的Flash.');
                                        }
                                    });
                                    /**
                                     * 删除单图, 更新数据
                                     */
                                    function delthispic{$data.id}(obj) {
                                        var dataids = '';   // 图片标识数据
                                        $(obj).parent().remove();               // 移除父结点
                                        // 更新数据
                                        $.CurrentNavtab.find('#cover_id_{$data.id}').val('');
                                    }
                                </script>
	                        	</div>
	                        </div>
                        </div>
                        <div class="col-md-12">
                            <div class="panel panel-default">
                                <div class="panel-heading">
                                    可见性
                                </div>
                                <div class="panel-body">
                                    <volist name=":parse_field_attr($fields['display']['extra'])" id="vo">
                                        <input type="radio" value="{$key}" name="display" <eq name="data['display']" value="$key">checked="checked"</eq>>{$vo}
                                    </volist>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-12">
                            <div class="panel panel-default">
                                <div class="panel-heading">
                                    推荐位
                                </div>
                                <div class="panel-body">
                                    <volist name=":parse_field_attr($fields['position']['extra'])" id="vo">
                                        <label><input type="checkbox" value="{$key}" name="position[]" <if condition="check_document_position($data['position'],$key)">checked="checked"</if>>{$vo}</label>
                                    </volist>
                                </div>
                            </div>
                        </div>
                        <!--<div class="col-md-12">
                            <div class="panel panel-default">
                                <div class="panel-heading">
                                    截至时间
                                    <span class="check-tips">
                                        （0-永久有效）
                                    </span>
                                </div>
                                <div class="panel-body">
                                    <input type="text" name="deadline" value="{$data['deadline']|date='Y-m-d',###}" data-toggle="datepicker" data-rule="date" placeholder="请选择日期" />
                                </div>
                            </div>
                        </div>-->
                        <div class="col-md-12">
                            <div class="panel panel-default">
                                <div class="panel-heading">
                                    创建时间
                                </div>
                                <div class="panel-body">
                                    <input type="text" name="create_time" value="{$data['create_time']|time_format}" data-toggle="datepicker" data-rule="date" placeholder="请选择日期" />
                                </div>
                            </div>
                        </div>
                        <div class="col-md-12">
                            <div class="panel panel-default">
                                <div class="panel-heading">
                                    收藏数
                                </div>
                                <div class="panel-body">
                                    <input type="text" value="{$data['bookmark']}" name="bookmark" class="text input-mid form-control">
                                </div>
                            </div>
                        </div>
                        <div class="col-md-12">
                            <div class="panel panel-default">
                                <div class="panel-heading">
                                    评论数
                                </div>
                                <div class="panel-body">
                                    <input type="text" value="{$data['comment']}" name="comment" class="text input-mid form-control">
                                </div>
                            </div>
                        </div>
                        <div class="col-md-12">
                            <div class="panel panel-default">
                                <div class="panel-heading">
                                    浏览量
                                </div>
                                <div class="panel-body">
                                    <input type="text" value="{$data['view']}" name="view" class="text input-mid form-control"></div>
                            </div>
                        </div>
	                    <div class="col-md-12">
	                        <div class="panel panel-default">
                                <div class="panel-heading">
                                    标识
                                </div>
	                            <div class="panel-body">
	                                <input type="text" value="{$data['name']}" name="name" class="text input-large form-control">
	                            </div>
	                        </div>
	                    </div>
                    </div>
                        </div>
                </div>
        </form>
    </div>
</block>